<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
    <script src="../js/lay-module/http/http.js"></script>
</head>
<body onload="init()">
<div class="layui-form layuimini-form">
    <div class="layui-form-item" hidden>
        <label class="layui-form-label required">项目主键</label>
        <div class="layui-input-block">
            <input type="text" name="id"  id="id" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item" hidden>
        <label class="layui-form-label required">项目ID</label>
        <div class="layui-input-block">
            <input type="text" name="project_id"  id="project_id" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">项目名称</label>
        <div class="layui-input-block">
            <input type="text" name="name"  id="name" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">启动时间</label>
        <div class="layui-input-block">
            <input type="text" id="startTime" name="startTime" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">结束时间</label>
        <div class="layui-input-block">
            <input type="text" id="endTime" name="endTime" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">简要介绍</label>
        <div class="layui-input-block">
            <input type="text" id="introduce" name="introduce" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">预期效果</label>
        <div class="layui-input-block">
            <input type="text" id="expectEffect" name="expectEffect" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">项目类型</label>
        <div class="layui-input-block">
            <input type="text" id="projectType" name="projectType" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">申报时间</label>
        <div class="layui-input-block">
            <input type="text" id="applicationTime" name="applicationTime" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item" hidden>
        <label class="layui-form-label required">所属公司</label>
        <div class="layui-input-block">
            <input type="text" id="firm" name="firm" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item" hidden>
        <label class="layui-form-label required">所属部门</label>
        <div class="layui-input-block">
            <input type="text" id="department" name="department" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">项目负责人</label>
        <div class="layui-input-block">
            <input type="text" id="principal" name="principal" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item" hidden>
        <label class="layui-form-label required">二维码</label>
        <div class="layui-input-block">
            <input type="text" id="qrCode" name="qrCode" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item" hidden>
        <label class="layui-form-label required">条形码</label>
        <div class="layui-input-block">
            <input type="text" id="barCode" name="barCode" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">是否验收</label>
        <div class="layui-input-block">
            <input type="text" id="checkAccept" name="checkAccept" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">项目状态</label>
        <div class="layui-input-block">
            <input type="text" id="state" name="state" value="" class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">项目成果</label>
        <div class="layui-input-block">
            <input type="text" id="achievement" name="achievement" value="" class="layui-input" readonly>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">编辑</button>
        </div>
    </div>
</div>

<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    function init(){
        var $ = layui.jquery

        // 2.获取用户当前的信息
        $.ajax({
            type: 'GET',
            url: $api + 'projectLibrary/project/select/one/project',
            contentType: "application/json;charset=utf-8",
            async: false,
            headers: {
                'Authorization': layui.data('table')['Authorization']
            },
            success: function (res) {
                // 2.1 根据查询到的数据对页面进行填充
                identifyCode(res)
                if (!res.code) {
                    // 设置<select>当前的选中项
                    var selectRole = 'dd[lay-value=' + res.data.role + ']';
                    var selectStatus = 'dd[lay-value=' + res.data.status + ']';
                    $("#id").val(res.data.id);
                    $("#project_id").val(res.data.project_id);
                    $("#name").val(res.data.name);
                    $("#startTime").val(res.data.startTime);
                    $("#endTime").val(res.data.endTime);
                    $("#introduce").val(res.data.introduce);
                    $("#expectEffect").val(res.data.expectEffect);
                    $("#projectType").val(getProjectType(res.data.projectType));
                    $("#applicationTime").val(res.data.applicationTime);
                    $("#firm").val(res.data.firm);
                    $("#department").val(res.data.department);
                    $("#principal").val(res.data.principal);
                    $("#qrCode").val(res.data.qrCode);
                    $("#barCode").val(res.data.barCode);
                    $("#evolve").val(res.data.evolve);
                    $("#putOnRecords").val(getPutOnRecords(res.data.putOnRecords));
                    $("#checkAccept").val(getCheckAccept(res.data.checkAccept));
                    $("#state").val(res.data.state);
                    $("#achievement").val(res.data.achievement);
                }else{
                    layer.msg(res.message)
                }

            }
        });
    }
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            window.location.href = "project-update.html"

        });

    });
</script>
</body>
</html>